#include <iostream>
#include <string>
using namespace std;

struct Node{
	Node * next[10];
	Node () {
		for(int i=0; i<10; i++)
			next[i] = NULL;
	}
};
bool isLeaf(Node *tree){
	if( tree == NULL ) return false;
	else {
		for(int i=0; i<10; i++){
			if( tree->next[i] != NULL ) return false;
		}
		return true;
	}
}
bool insert(Node **tree,string number,int i,int length){
	bool ret = false;
	int num = number[i]-'0';
	if( i != length ){
		if( (*tree)==NULL ){
			*tree = new Node();
			ret = insert(&((*tree)->next[num]),number,i+1,length);
		}else{
			if( isLeaf((*tree)->next[num]) ) ret = false;
			else ret = insert(&((*tree)->next[num]),number,i+1,length);	
		} 
	}else{
		if( (*tree) == NULL ) {
			*tree = new Node();
			ret =  true;
		}else ret = false;
	}
	return ret;
}
void clear(Node *tree){
	if( tree ){
		for(int i=0; i<10; i++){
			clear(tree->next[i]);	
		}
		delete tree;
	}
}
int main(){
	freopen("in.txt","r",stdin);
	int t;
	cin >> t;
	for(int i=0; i<t; i++){
		int n;
		cin >> n;
		int flag = 0;
		Node *tree = NULL;
		for(int j=0; j<n; j++){
			string number;
			cin >> number;
			if( flag==0 ){
				if( !insert(&tree,number,0,number.length()) ) flag = 1;
			}
		}
		if( flag == 0 ) cout << "YES" << endl;
		else cout << "NO" << endl;
		clear(tree);
	}
	return 0;
}
